<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<%@include file="/common/head.jsp" %>
<style type="text/css">
    .errstyle {border:1px solid red;}
    .bor {border:1px solid #C0C0C0;}
    form span{
        color: red;
        position: relative;
        top: 3px;
    }
</style>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/validate-idnumber.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.validate.custom.js"></script>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <p align="center"><font size="5" color="black" face="楷体">基本信息</font></p>
    <form action="${ctx }/admin/employee/save1?id=${n.id}" id="detail-form" class="form-horizontal" method="post">

        <div class="form-group">
            <!-- 用户ID -->
            <input type="hidden" id="user-id" name="user.id" value="${n.user.id }" class="form-control">
            <%--<label class="col-sm-2 control-label">用户ID</label>
            <div class="col-sm-4">
                <input type="hidden" id="user-id" name="user.id" value="${n.user.id }" class="form-control">
                <input type="text"  placeholder="请选择用户ID" class="form-control"  id="user-name" name="user.username" value="${n.user.id}"
                       onclick="bring({
                               url:'${ctx}/admin/user/search',
                               name: 'username',
                               idInput: 'user-id',
                               nameInput: 'user-name'
                               })" />--%>
            <label class="col-sm-2 control-label">工作部门</label>
            <div class="col-sm-4">
                <input type="hidden" id="department-id" name="department.id" value="${n.department.id }" class="form-control">
                <input type="text"  placeholder="请选择部门" class="form-control"  id="department-name" name="department.name" value="${n.department.id}"
                       onclick="bring({
                               url:'${ctx}/admin/department/search',
                               name: 'name',
                               idInput: 'department-id',
                               nameInput: 'department-name'
                               })" />
            </div>

            <!-- 岗位 -->
            <label class="col-sm-2 control-label">岗位</label>
            <div class="col-sm-4">
                <!--<input type="text" class="form-control" name="position" value="${n.position }">-->
  <%--              <select  id=position name="position">
                    <option value ="JAVA" ></option>
                    <option value ="JAVA" >JAVA</option>
                    <option value ="前端" >前端</option>
                    <option value="安卓"  >安卓</option>
                    <option value="产品"  >产品经理</option>
                </select>--%>
                <select id=position name="position">
                    <option value ="-1" <c:if test="${n.position==null}">selected</c:if>>...</option>
                    <option value ="前端" <c:if test="${n.position=='1'}">selected</c:if>>前端</option>
                    <option value ="JAVA" <c:if test="${n.position=='0'}">selected</c:if> >JAVA</option>
                    <option value="安卓"  <c:if test="${n.position=='2'}">selected</c:if>>安卓</option>
                    <option value="产品经理"  <c:if test="${n.position=='3'}">selected</c:if>>产品经理</option>
                </select>
            </div>
        </div>
        <div class="form-group">

            <!-- 姓名 -->
            <label class="col-sm-2 control-label">姓名</label>
            <div class="col-sm-4">
                <input id="name" placeholder="必填项" type="text" class="form-control" name="name" value="${n.name }">
            </div>

            <!-- 出生日期 -->
            <label class="col-sm-2 control-label">出生日期</label>
            <div class="col-sm-4">
                <input placeholder="必填项" id="birth" type="text" class="form-control" name="birth" value="<fmt:formatDate value='${n.birth }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
            </div>
        </div>
        <div class="form-group">

            <!-- 性别 -->
            <label class="col-sm-2 control-label">性别</label>
            <div class="col-sm-4">
                <select  id="select6" name="sex">
                    <option value ="0" ></option>
                    <option value ="1" >男</option>
                    <option value ="2" >女</option>
                </select>
            </div>

            <!-- 身高 -->
            <label class="col-sm-2 control-label">身高</label>
            <div class="col-sm-3">
                <input id="input4" type="text" class="form-control" name="height" value="${n.height }">
            </div>
            <div class="col-sm-1">
                cm
            </div>
        </div>
        <div class="form-group">

            <!-- 体重 -->
            <label class="col-sm-2 control-label">体重</label>
            <div class="col-sm-3">
                <input id="input5" type="text" class="form-control" name="weight" value="${n.weight }">
            </div>
            <div class="col-sm-1">
                kg
            </div>

            <!-- 籍贯 -->
            <label class="col-sm-2 control-label">籍贯</label>
            <div class="col-sm-4">
                <input id="place" placeholder="必填项" type="text" class="form-control" name="place" value="${n.place }">
            </div>
        </div>
        <div class="form-group">

            <!-- 民族 -->
            <label class="col-sm-2 control-label">民族</label>
            <div class="col-sm-4">
                <input id="nation" placeholder="必填项" type="text" class="form-control" name="nation" value="${n.nation }">
            </div>

            <!-- 联系电话 -->
            <label class="col-sm-2 control-label">联系电话</label>
            <div class="col-sm-4">
                <input id="phone" placeholder="必填项" type="text" class="form-control" name="phone" value="${n.phone }">
                <label style="color: red" class="errorClass" id="phoneError">${errors.phone }</label>
            </div>
        </div>
        <div class="form-group">

            <!-- 身份证号 -->
            <label class="col-sm-2 control-label">身份证号</label>
            <div class="col-sm-4">
                <input id="IDCard" type="text" placeholder="必填项" class="form-control" name="IDCard" value="${n.IDCard }">
                <label style="color: red" class="errorClass" id="IDCardError">${errors.IDCard }</label>
            </div>

            <!-- 毕业学校 -->
            <label class="col-sm-2 control-label">毕业学校</label>
            <div class="col-sm-4">
                <input id="school" type="text" placeholder="必填项" class="form-control" name="school" value="${n.school }">
            </div>
        </div>
        <div class="form-group">

            <!-- 专业 -->
            <label class="col-sm-2 control-label">专业</label>
            <div class="col-sm-4">
                <input id="major" type="text" placeholder="必填项" class="form-control" name="major" value="${n.major }">
            </div>

            <!-- 学历 -->
            <label class="col-sm-2 control-label">学历</label>
            <div class="col-sm-4">

                <select  id="education" name="education">
                    <option value ="-1" <c:if test="${n.education==null}">selected</c:if>>...</option>
                    <option value ="0" <c:if test="${n.education=='0'}">selected</c:if> >专科</option>
                    <option value ="1" <c:if test="${n.education=='1'}">selected</c:if>>本科</option>
                    <option value="2"  <c:if test="${n.education=='2'}">selected</c:if>>硕士</option>
                    <option value="3"  <c:if test="${n.education=='3'}">selected</c:if>>博士</option>
                </select>
            </div>
        </div>
        <div class="form-group">

            <!-- 户口所在地 -->
            <label class="col-sm-2 control-label">户口所在地</label>
            <div class="col-sm-4">
                <input id="location" type="text" placeholder="必填项" class="form-control" name="location" value="${n.location }">
            </div>

            <!-- 居住地址 -->
            <label class="col-sm-2 control-label">居住地址</label>
            <div class="col-sm-4">
                <input id="address" placeholder="必填项" type="text" class="form-control" name="address" value="${n.address }">
            </div>
        </div>
        <div class="form-group">

            <!-- 微信号 -->
            <label class="col-sm-2 control-label">微信号</label>
            <div class="col-sm-4">
                <input id="input14" type="text" class="form-control" name="wechat" value="${n.wechat }">
            </div>

            <!-- 邮箱 -->
            <label class="col-sm-2 control-label">邮箱</label>
            <div class="col-sm-4">
                <input id="email" placeholder="必填项" type="text" class="form-control" name="email" value="${n.email }">
            </div>
        </div>
        <div class="form-group">

            <!-- 婚姻状况 -->
            <label class="col-sm-2 control-label">婚姻状况</label>
            <div class="col-sm-4">
                <!--  <input type="text" class="form-control" name="marry" value="${n.marry }">
                <input type="radio" name="marry" value="1">未婚</input>
                 <input type="radio" name="marry" value="2">已婚</input>
                 <input type="radio" name="marry" value="0">离异</input>-->
                <select id="marry" name="marry">
                    <option value ="0" ></option>
                    <option value ="1" >未婚</option>
                    <option value ="2" >已婚</option>
                    <option value="3"  >离异</option>
                </select>
            </div>

            <!-- 入职时间 -->
            <label class="col-sm-2 control-label">入职时间</label>
            <div class="col-sm-4">
                <input id="inTime" placeholder="必填项" type="text" class="form-control" name="inTime" value="<fmt:formatDate value='${n.inTime }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
            </div>
        </div>
        <div style="display: none" class="form-group">

            <!-- 员工状态/1.录用/2.停职 -->
            <label class="col-sm-2 control-label">员工状态</label>
            <div class="col-sm-4">
                <select id="select4" name="status">
                    <%--<option value ="0" ></option>--%>
                    <option value ="0" >入职</option>
                    <%--<option value ="2" >转正</option>--%>
                    <%--<option value="3"  >离职</option>--%>
                </select>
            </div>
        </div>


        <p align="center"><font size="5" color="black" face="楷体">紧急联系人</font></p>
        <hr align="center"  size="3"  color="#00FFFF"/>
        <div class="wrapper wrapper-content animated fadeInRight" id="div2">
            <div class="form-group">
                <!-- 姓名 -->
                <label class="col-sm-2 control-label">姓名</label>
                <div class="col-sm-4">
                    <input id="emname" type="text" placeholder="必填项" class="form-control" name="em_name" >
                </div>

                <!-- 关系 -->
                <label class="col-sm-2 control-label">关系</label>
                <div class="col-sm-4">
                    <input id="relation" type="text" placeholder="必填项" class="form-control" name="relation">
                </div>
            </div>
            <div class="form-group">
                <!-- 联系电话 -->
                <label class="col-sm-2 control-label">联系电话</label>
                <div class="col-sm-4">
                    <input id="emphone" type="text" placeholder="必填项" class="form-control" name="em_phone">
                    <label style="color: red" class="errorClass" id="emphoneError">${errors.emphone }</label>
                </div>

                <!-- 单位或住址 -->
                <label class="col-sm-2 control-label">单位或住址</label>
                <div class="col-sm-4">
                    <input id="emaddress" type="text" placeholder="必填项" class="form-control" name="em_address" >
                </div>
            </div>
        </div>
        <div id="div22"></div>
        <div align="center">
            <%--<input type="button" class="btn btn-default" value="添加记录"/>--%>
            <button type="button" class="btn-1 btn-primary">添加联系人</button>
            <hr align="center" size="3" color="#00FFFF"/>
        </div>





        <p align="center"><font size="5" color="black" face="楷体">教育及培训情况</font></p>
        <hr align="center" size="3" color="#00FFFF"/>
        <div class="wrapper wrapper-content animated fadeInRight" id="div1">
            <div class="form-group">
                <!-- 学习起始时间 -->
                <label class="col-sm-2 control-label">学习起始时间</label>
                <div class="col-sm-4">
                    <input id="start" type="text" placeholder="必填项" class="form-control" name="start"
                           onclick="laydate({format: 'YYYY-MM-DD'})">
                </div>
                <!-- 学习结束时间 -->
                <label class="col-sm-2 control-label">学习结束时间</label>
                <div class="col-sm-4">
                    <input id="end" type="text" placeholder="必填项" class="form-control" name="end"
                           onclick="laydate({format: 'YYYY-MM-DD'})">
                </div>
            </div>
            <div class="form-group">
                <!-- 专业 -->
                <label class="col-sm-2 control-label">专业</label>
                <div class="col-sm-4">
                    <input id="edmajor" type="text" placeholder="必填项" class="form-control" name="majors" >
                </div>
                <!-- 学历 -->
                <label class="col-sm-2 control-label">学历</label>
                <div class="col-sm-4">
                    <select  id="record" name="record">
                        <option value ="-1" <c:if test="${n1.record==null}">selected</c:if>>...</option>
                        <option value ="0" <c:if test="${n1.record=='0'}">selected</c:if> >专科</option>
                        <option value ="1" <c:if test="${n1.record=='1'}">selected</c:if>>本科</option>
                        <option value="2"  <c:if test="${n1.record=='2'}">selected</c:if>>硕士</option>
                        <option value="3"  <c:if test="${n1.record=='3'}">selected</c:if>>博士</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <!-- 证书 -->
                <label class="col-sm-2 control-label">证书</label>
                <div class="col-sm-4">
                    <input id="certificate" type="text" placeholder="必填项" class="form-control" name="certificate">
                </div>
            </div>
        </div>
        <div id="div11"></div>
        <div align="center">
            <button type="button" class="btn-2 btn-primary">添加教育/培训情况</button>
            <hr align="center" size="3" color="#00FFFF"/>
        </div>





        <p align="center"><font size="5" color="black" face="楷体">工作经历</font></p>
        <hr align="center"  size="3"  color="#00FFFF"/>
        <div class="wrapper wrapper-content animated fadeInRight" id="div3">
            <div class="form-group">
                <!-- 工作起始时间 -->
                <label class="col-sm-2 control-label">工作起始时间</label>
                <div class="col-sm-4">
                    <input id="input25" type="text" class="form-control" name="ex_start"
                           onclick="laydate({format: 'YYYY-MM-DD'})">
                </div>

                <!-- 工作结束时间 -->
                <label class="col-sm-2 control-label">工作结束时间</label>
                <div class="col-sm-4">
                    <input id="input26" type="text" class="form-control" name="ex_end"
                           onclick="laydate({format: 'YYYY-MM-DD'})">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">离职原因</label>
                <div class="col-sm-4">
                    <input id="input27" type="text" class="form-control" name="reason" >
                </div>

                <!-- 单位 -->
                <label class="col-sm-2 control-label">单位</label>
                <div class="col-sm-4">
                    <input id="input28" type="text" class="form-control" name="company">
                </div>
            </div>
            <div class="form-group">
                <!-- 工作 -->
                <label class="col-sm-2 control-label">工作</label>
                <div class="col-sm-4">
                    <input id="input29" type="text" class="form-control" name="work">
                </div>

                <!-- 职位 -->
                <label class="col-sm-2 control-label">职位</label>
                <div class="col-sm-4">
                    <input id="input30" type="text" class="form-control" name="ex_position" >
                </div>
            </div>
        </div>
        <div id="div33"></div>
        <div align="center">
            <button type="button" class="btn-3 btn-primary" >添加工作经历</button>
            <hr align="center" size="3" color="#00FFFF"/>
        </div>

        <p align="center"><font size="5" color="black" face="楷体">家庭成员及主要社会关系</font></p>
        <hr align="center" size="3" color="#00FFFF"/>
        <div class="wrapper wrapper-content animated fadeInRight" id="div4">
            <!-- 姓名 -->
            <div class="form-group">
                <%--<div >--%>
                <%--<input type="hidden"  name="employee.id" class="form-control">--%>
                <%--</div>--%>
                <label class="col-sm-2 control-label">姓名</label>
                <div class="col-sm-4">
                    <input id="fname" type="text" placeholder="必填项" class="form-control" name="f_name" >
                </div>

                <!-- 关系 -->
                <label class="col-sm-2 control-label">关系</label>
                <div class="col-sm-4">
                    <input id="frelation" type="text" placeholder="必填项" class="form-control" name="f_relation">
                </div>
            </div>
            <div class="form-group">
                <!-- 联系方式 -->
                <label class="col-sm-2 control-label">联系电话</label>
                <div class="col-sm-4">
                    <input id="contact" type="text" placeholder="必填项" class="form-control" name="contact" >
                    <label style="color: red" class="errorClass" id="contactError">${errors.emphone }</label>
                </div>

                <!-- 年龄 -->
                <label class="col-sm-2 control-label">年龄</label>
                <div class="col-sm-4">
                    <input id="input34" type="text" class="form-control" name="age">
                </div>
            </div>
            <div class="form-group">

                <!-- 工作单位 -->
                <label class="col-sm-2 control-label">工作单位</label>
                <div class="col-sm-4">
                    <input id="input35" type="text" class="form-control" name="f_company">
                </div>
                <!-- 职位 -->
                <label class="col-sm-2 control-label">职位</label>
                <div class="col-sm-4">
                    <input id="input36" type="text" class="form-control" name="f_position" >
                </div>
            </div>
        </div>
        <div id="div44"></div>
        <div align="center">
            <button type="button" class="btn-4 btn-primary" >添加家庭成员</button>
            <hr align="center" size="3" color="#00FFFF"/>
        </div>
<%--        <div align="center">
            <input type="button" class="btn-4 btn-primary" value="添加录" />
            <hr align="center" size="3" color="#00FFFF"/>
        </div>--%>

    </form>
    <div>
        <p align="center">
            <!--  <input type="button" onclick="dosubmit();" value="保存"/>
              <input type="submit" name="Submit" value="确认提交" class="sub-btn btn btn-sm btn-outline btn-primary"/>-->
            <button id="save" type="button" style="font-size: 15px"  class="btn btn-sm btn-outline btn-info" ><i class="fa fa-check"></i>确认提交</button>
        </p>
    </div>

</div>
<%@include file="/common/foot.jsp" %>
<script type="text/javascript">
  /*  $(document).on("click", ".sub-btn", function () {
        var form = $(this).parents("form");

        form.ajaxSubmit({
            success: function(data) {
                if (isSuccess(data)) {
                    reload();
                  //  location.reload()
                } else {
                }
            }
        });
    });*/

    //添加家庭成员
    $(document).on("click",".btn-4",function(){
//            var node = document.getElementById("div4");
//            var cloneNode = node.cloneNode(true);
//            node.parentNode.appendChild(cloneNode);
        var html = document.getElementById('family').innerHTML;
        $("#div44").append(html);
    })
    //添加工作经历
    $(document).on("click",".btn-3",function(){
//            var node = document.getElementById("div3");
//            var cloneNode = node.cloneNode(true);
//            node.parentNode.appendChild(cloneNode);
        var html = document.getElementById('experience').innerHTML;
        $("#div33").append(html);
    })
    //添加学历
    $(document).on("click",".btn-2",function(){
//              var node = document.getElementById("div1");
//              var cloneNode = node.cloneNode(true);
//              $("#div11").append(cloneNode);
        var html = document.getElementById('educationadd').innerHTML;
        $("#div11").append(html);
    })

    //添加联系人
    $(document).on("click",".btn-1",function(){
//            var node = document.getElementById("div2");
//            var cloneNode = node.cloneNode(true);
//            node.parentNode.appendChild(cloneNode);
        var html = document.getElementById('contactadd').innerHTML;
        $("#div22").append(html);
    })
</script>

    <%--学历管理--%>
<script type="text/template" id="educationadd">

    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="form-group">
            <%--<!-- 学习起始时间 -->--%>
            <label class="col-sm-2 control-label">学习起始时间</label>
            <div class="col-sm-4">
                <input type="text"  class="form-control" name="start"
                       onclick="laydate({format: 'YYYY-MM-DD'})">
            </div>
            <!-- 学习结束时间 -->
            <label class="col-sm-2 control-label">学习结束时间</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="end"
                       onclick="laydate({format: 'YYYY-MM-DD'})">
            </div>
        </div>
        <div class="form-group">
            <!-- 专业 -->
            <label class="col-sm-2 control-label">专业</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="majors" >
            </div>
            <!-- 学历 -->
            <label class="col-sm-2 control-label">学历</label>
            <div class="col-sm-4">
                <select  id="select7" name="record">
                    <option value ="-1" <c:if test="${n1.record==null}">selected</c:if>>...</option>
                    <option value ="0" <c:if test="${n1.record=='0'}">selected</c:if> >专科</option>
                    <option value ="1" <c:if test="${n1.record=='1'}">selected</c:if>>本科</option>
                    <option value="2"  <c:if test="${n1.record=='2'}">selected</c:if>>硕士</option>
                    <option value="3"  <c:if test="${n1.record=='3'}">selected</c:if>>博士</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <!-- 证书 -->
            <label class="col-sm-2 control-label">证书</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="certificate">
            </div>
        </div>
        <div align="right"><button type="button"  class="btn btn-primary" onclick="removeEducation(this)">删除</button></div>
    </div>
</script>

    <%--紧急联系人--%>
<script type="text/template" id="contactadd">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="form-group">
            <!-- 姓名 -->
            <label class="col-sm-2 control-label">姓名</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="em_name" >
            </div>

            <!-- 关系 -->
            <label class="col-sm-2 control-label">关系</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="relation">
            </div>
        </div>
        <div class="form-group">
            <!-- 联系电话 -->
            <label class="col-sm-2 control-label">联系电话</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="em_phone">
            </div>

            <!-- 单位或住址 -->
            <label class="col-sm-2 control-label">单位或住址</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="em_address" >
            </div>
        </div>
        <div align="right"><button type="button"  class="btn btn-primary" onclick="removeEducation(this)">删除</button></div>
    </div>
</script>

    <%--工作经验管理--%>
<script type="text/template" id="experience">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="form-group">
            <!-- 工作起始时间 -->
            <label class="col-sm-2 control-label">工作起始时间</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="ex_start"
                       onclick="laydate({format: 'YYYY-MM-DD'})">
            </div>

            <!-- 工作结束时间 -->
            <label class="col-sm-2 control-label">工作结束时间</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="ex_end"
                       onclick="laydate({format: 'YYYY-MM-DD'})">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">离职原因</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="reason" >
            </div>

            <!-- 单位 -->
            <label class="col-sm-2 control-label">单位</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="company">
            </div>
        </div>
        <div class="form-group">
            <!-- 工作 -->
            <label class="col-sm-2 control-label">工作</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="work">
            </div>

            <!-- 职位 -->
            <label class="col-sm-2 control-label">职位</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="ex_position" >
            </div>
        </div>
        <div align="right"><button type="button"  class="btn btn-primary" onclick="removeEducation(this)">删除</button></div>
    </div>
</script>

    <%--家庭成员管理--%>
<script type="text/template" id="family">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="form-group">
            <%--<div >--%>
            <%--<input type="hidden"  name="employee.id" class="form-control">--%>
            <%--</div>--%>
            <label class="col-sm-2 control-label">姓名</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="f_name" >
            </div>

            <!-- 关系 -->
            <label class="col-sm-2 control-label">关系</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="f_relation">
            </div>
        </div>
        <div class="form-group">
            <!-- 联系方式 -->
            <label class="col-sm-2 control-label">联系方式</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="contact" >
            </div>

            <!-- 年龄 -->
            <label class="col-sm-2 control-label">年龄</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="age">
            </div>
        </div>
        <div class="form-group">

            <!-- 工作单位 -->
            <label class="col-sm-2 control-label">工作单位</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="f_company">
            </div>
            <!-- 职位 -->
            <label class="col-sm-2 control-label">职位</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="f_position" >
            </div>
        </div>
        <div align="right"><button type="button"  class="btn btn-primary" onclick="removeEducation(this)">删除</button></div>
    </div>
</script>

<script type="text/javascript">

    function removeEducation(obj) {
        $(obj).parent().parent().remove();
    }


    $(function() {
        /*
         * 1. 得到所有的错误信息，循环遍历之。调用一个方法来确定是否显示错误信息！
         */
        $(".errorClass").each(function() {
            showError($(this));//遍历每个元素，使用每个元素来调用showError方法
        });
        /*
         * 3. 输入框得到焦点隐藏错误信息
         */
        $(".form-control").focus(function() {
           clearerr($(this));
            var labelId = $(this).attr("id") + "Error";//通过输入框找到对应的label的id
            $("#" + labelId).text("");//把label的内容清空！
            showError($("#" + labelId));//隐藏没有信息的label

        });
        /*
         * 4. 输入框失去焦点进行校验
         */

        $(".form-control").blur(function() {
            var id = $(this).attr("id");//获取当前输入框的id

            if(id!="department-name"){
             checkInput($(this));
           }
            var funName = "validate" + id.substring(0,1).toUpperCase() + id.substring(1) + "()";//得到对应的校验函数名
            eval(funName);//执行函数调用
        });
    });
    /*
     * 身份证号校验方法
     */
    function validateIDCard() {
        var id = "IDCard";
        var value = validateIdNumber($("#" + id).val());//调用IDCard的校验函数
        /*
         * 1. 非空校验
         */
        if(value==0) {
            /*
             * 获取对应的label
             * 添加错误信息
             * 显示label
             */
            $("#" + id + "Error").text("身份证号码不能为空！");
            showError($("#" + id + "Error"));
            return false;
        }else if(value==1) {
            /*
             * 获取对应的label
             * 添加错误信息
             * 显示label
             */
            $("#" + id + "Error").text("");
            showError($("#" + id + "Error"));
            return false;
        }else{
            /*
             * 获取对应的label
             * 添加错误信息
             * 显示label
             */
            $("#" + id + "Error").text("请输入有效的身份证号码！");
            showError($("#" + id + "Error"));
            return false;
        }
    }
    /*
     * 身份证号校验方法
     */
    function validatePhone() {
        var id = "phone";
        var val = $("#" + id).val()
        if (val =="") {
            /*
             * 获取对应的label
             * 添加错误信息
             * 显示label
             */
            $("#" + id + "Error").text("手机号码不能为空！");
            showError($("#" + id + "Error"));
            return false;
        } else {
            var value = mobileValidation(val);//调用IDCard的校验函数
            if (!value) {
                /*
                 * 获取对应的label
                 * 添加错误信息
                 * 显示label
                 */
                $("#" + id + "Error").text("请输入有效的手机号码！");
                showError($("#" + id + "Error"));
                return false;
            }
        }
    }

    function validateEmphone() {
        var id = "emphone";
        var val = $("#" + id).val()
        if (val =="") {
            /*
             * 获取对应的label
             * 添加错误信息
             * 显示label
             */
            $("#" + id + "Error").text("手机号码不能为空！");
            showError($("#" + id + "Error"));
            return false;
        } else {
            var value = mobileValidation(val);//调用IDCard的校验函数
            if (!value) {
                /*
                 * 获取对应的label
                 * 添加错误信息
                 * 显示label
                 */
                $("#" + id + "Error").text("请输入有效的手机号码！");
                showError($("#" + id + "Error"));
                return false;
            }
        }
    }

    function validateContact() {
        var id = "contact";
        var val = $("#" + id).val()
        if (val =="") {
            /*
             * 获取对应的label
             * 添加错误信息
             * 显示label
             */
            $("#" + id + "Error").text("手机号码不能为空！");
            showError($("#" + id + "Error"));
            return false;
        } else {
            var value = mobileValidation(val);//调用IDCard的校验函数
            if (!value) {
                /*
                 * 获取对应的label
                 * 添加错误信息
                 * 显示label
                 */
                $("#" + id + "Error").text("请输入有效的手机号码！");
                showError($("#" + id + "Error"));
                return false;
            }
        }
    }

    function showError(ele) {
        var text = ele.text();//获取元素的内容
        if(!text) {//如果没有内容
            ele.css("display", "none");//隐藏元素
        } else {//如果有内容
            ele.css("display", "");//显示元素
        }
    }

    $(document).on("click", "#save", function () {
        var flag=dosubmit();
        if(flag){
            layer.confirm('确认要提交吗?', {icon: 3, title:'提示'}, function(index){
                var form = $("#user-id").parents("form");
                form.ajaxSubmit({
                    success: function(data) {
                       /* if (isSuccess(data)) {
                            // reload();
                        } else {
                        }*/
                        location.href="${ctx}/admin/employee/details4";
                    }
                });

            });
        }else{

            alert("有必填项未填写！");
        }
    });

</script>


<script type="text/javascript">

    //检查input
    function checkInput(obj) {
        var val = obj.val();
        if(val == "") {
            //obj.className = "errstyle";
            obj.css("border","#CC0033 1px solid");
            return false;
        } else {
            return true;
        }
    }
    function checkSelect1(obj) {
        var val = obj.val();
        alert(val);
        if(val == "") {
            //obj.className = "errstyle";
            obj.css("border","#CC0033 1px solid");
            return false;
        } else {
            return true;
        }
    }
    //获取焦点时清除错误
    function clearerr(obj) {
        obj.css("border","");
    }
    //提交校验
    function dosubmit() {
        var position = checkInput($("#position"));
        var major = checkInput($("#major"));

        var name = checkInput($("#name"));
        var birth = checkInput($("#birth"));
        var place = checkInput($("#place"));
        var nation = checkInput($("#nation"));
        var phone = checkInput($("#phone"));
        var IDCard= checkInput($("#IDCard"));
        var school = checkInput($("#school"));
        var education= checkInput($("#education"));
        var address = checkInput($("#address"));
        var location= checkInput($("#location"));
        var email = checkInput($("#email"));
        var marry = checkInput($("#marry"));
        var inTime= checkInput($("#inTime"));
        var emname= checkInput($("#emname"));
        var relation = checkInput($("#relation"));
        var emphone = checkInput($("#emphone"));
        var emaddress = checkInput($("#emaddress"));
        var start = checkInput($("#start"));
        var end = checkInput($("#end"));
        var edmajor = checkInput($("#edmajor"));
        var record = checkInput($("#record"));
        var certificate = checkInput($("#certificate"));
        var fname = checkInput($("#fname"));
        var frelation = checkInput($("#frelation"));
        var contact= checkInput($("#contact"));
        if(position&&major&&name&&birth && place&& nation &&phone&& IDCard&& school&& education&& address&& location&&
            email&& marry&& inTime&& emname&& relation&& emphone&& emaddress&& start&& end&& edmajor&& record&&
            certificate&& fname&& frelation&& contact) {
            //提交表单代码
            return true;
        } else {
            return false;
        }
    }
</script>
</body>
</html>
